//
//  UWViewController.m
//  Urban Words
//
//  Created by sebastian on 2011-11-18.
//  Copyright (c) 2011 Sypreme. All rights reserved.
//

#import "UWLoginController.h"

@implementation UWLoginController
@synthesize maintitle;
@synthesize subtitle;
@synthesize footermsg;

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    appDelegate = (UWAppDelegate *)[[UIApplication sharedApplication] delegate];
    
    subtitle.font = [UIFont fontWithName:@"HelveticaNeueLTPro-Cn" size:24];
    footermsg.font = [UIFont fontWithName:@"HelveticaNeueLTPro-Cn" size:16];
    
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
}

- (void)viewDidUnload
{
    [self setSubtitle:nil];
    [self setMaintitle:nil];
    [self setFootermsg:nil];
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    appDelegate = nil;
    // e.g. self.myOutlet = nil;
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
}

- (void)viewWillDisappear:(BOOL)animated
{
	[super viewWillDisappear:animated];
}

- (void)viewDidDisappear:(BOOL)animated
{
	[super viewDidDisappear:animated];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
        return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
    } else {
        return YES;
    }
}

- (IBAction)connect:(id)sender {
    if (![appDelegate.facebook isSessionValid]) {
        NSArray *permissions = [[NSArray alloc] initWithObjects:
                                @"read_friendlists", 
                                @"publish_actions",
                                @"publish_stream",
                                @"manage_notifications",
                                @"offline_access",
                                nil];
        
        [appDelegate.facebook authorize:permissions];
        [permissions release];
    }
}

- (void)dealloc {
    [subtitle release];
    [maintitle release];
    [footermsg release];
    [super dealloc];
}
@end
